package diwuzhang;

/**
 * Created by mc on 2016/7/25.
 */
public class shier
{
    public static void main(String[] arge)
    {
        int[][] maze={{2,2,2,2,2,2,2},{0,0,0,0,0,0,2},{2,0,2,0,2,0,2},{2,0,0,2,0,2,2},{2,2,0,2,0,2,2},{2,0,0,0,0,0,2},{2,2,2,2,2,0,2}};
        int a,b,c,d,e,f;
        f=0;
        e=0;
        int x[]=new int[100];
        int y[]=new int[100];
        x[0]=1;
        y[0]=0;
        c=0;
        d=0;
        a=1;
        b=0;
        while(a!=6||b!=5)
        {
            if(maze[a+1][b]==0&&maze[a][b+1]==0)
            {
                c=a;
                d=b;
                a=a+1;
                e=e+1;
                x[e]=a;
                y[e]=b;
            }
            else if(maze[a+1][b]==0&&maze[a][b+1]!=0)
            {

                a=a+1;
                e=e+1;
                x[e]=a;
                y[e]=b;
            }
            else if(maze[a+1][b]!=0&&maze[a][b+1]==0)
            {
                b=b+1;
                e=e+1;
                x[e]=a;
                y[e]=b;
            }
            else if(maze[a+1][b]!=0&&maze[a][b+1]!=0)
            {
                a=c;
                b=d;
                x[e]=a;
                y[e]=b;
            }

        }
        while(x[f]!=0||y[f]!=0)
        {
            System.out.println(x[f]+","+y[f]);
            f=f+1;
        }
    }
}
